package com.example.demo.filter;


import javax.servlet.*;
import javax.servlet.annotation.WebFilter;
import java.io.IOException;

/**
 * @ClassName FirstFilter
 * @Description FirstFilter 使用注解@WebFilter
 * @Author ZX
 * @Date 2020/5/26 9:36
 */
//@WebFilter(filterName = "FirstFilter",urlPatterns = {"*.do","*.jsp"}) //指定拦截的文件
@WebFilter(filterName = "FirstFilter",urlPatterns = {"/first"}) //指定拦截的url
public class FirstFilter implements Filter {
    @Override
    public void init(FilterConfig filterConfig) throws ServletException {

    }

    @Override
    public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) throws IOException, ServletException {
        System.out.println("进入First Filter...");
        filterChain.doFilter(servletRequest,servletResponse);
        System.out.println("离开First Filter...");
    }

    @Override
    public void destroy() {

    }
}
